<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>v-on:keydown</title>
		<script src="../js/vue.js"></script>
	</head>

	<body>
		<div id="app">
			<input type="text" v-on:keydown="fun($event)">
		</div>
	</body>
	<script>
		new Vue({
			el: '#app',
			data: {

			},
			methods: {
			    fun: function(event) {
					var keyCode = event.keyCode;
					if (keyCode > 57) {
                        event.preventDefault();
					} else if (keyCode < 48 && keyCode != 8) {
                        event.preventDefault();
					}
				}
			}
		});
	</script>
</html>